package com.zyg.dao;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.zyg.pojo.Hostel;
import com.zyg.pojo.Grade;
import org.apache.ibatis.annotations.*;

import java.util.List;


public interface HostelMapper extends BaseMapper<Hostel> {
    @Override
    @Select("select hostel_id,hostel_name,grade_id from hostel ${ew.customSqlSegment}")
    @Results({
            @Result(property = "hostelId", column = "hostel_id"),
            @Result(property = "hostelName", column = "hostel_name"),
            @Result(property = "grade", column = "grade_id", javaType = Grade.class,
                    one = @One(select = "com.zyg.dao.GradeMapper.selectById"))
    })
    List<Hostel> selectList(IPage<Hostel> page, @Param(Constants.WRAPPER) Wrapper<Hostel> queryWrapper);
}
